//
//  CurrentJobController.swift
//  ExpressDriver
//
//  Created by sheng on 2017/11/7.
//  Copyright © 2017年 sheng. All rights reserved.
//


import UIKit
import SnapKit

class CurrentJobController: UIViewController {
    
        
    @IBOutlet weak var segmented: UISegmentedControl!
    
    @IBOutlet weak var orderListView: UIView!
    
    @IBOutlet weak var orderMapView: UIView!
    
    let statusHeight = UIApplication.shared.statusBarFrame.height
    let scrrenHeight = UIScreen.main.bounds.height
    let scrrenWidth = UIScreen.main.bounds.width
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: .plain, target: nil, action: nil)
        self.view.backgroundColor = UIColor.white

        //setUI();
        let navigHeight = self.navigationController!.navigationBar.frame.height
        let height = statusHeight + navigHeight + 30 + 15 + 15
        
        segmented.snp.makeConstraints { (make) in
            make.top.equalTo(statusHeight + navigHeight + 15)
            make.width.equalTo((scrrenWidth * 2)/3)
            make.height.equalTo(30)
            make.centerX.equalTo(self.view)
        }
        
        
        orderListView.backgroundColor = UIColor.green
        orderListView.snp.makeConstraints { (make) in
            make.top.equalTo(segmented.snp.bottom).offset(15)
            make.left.right.equalTo(0)
            make.width.equalTo(scrrenWidth)
            make.height.equalTo(scrrenHeight - height)
        }
        
        orderMapView.snp.makeConstraints { (make) in
            make.top.equalTo(segmented.snp.bottom).offset(15)
            make.left.right.equalTo(0)
            make.width.equalTo(scrrenWidth)
            make.height.equalTo(scrrenHeight - height)
        }
        
        segmented.selectedSegmentIndex = 0
        orderListView.isHidden = false
        orderMapView.isHidden = true
    }
    
    
    @IBAction func segmentedIndexChanged(_ sender: UISegmentedControl) {
        switch segmented.selectedSegmentIndex {
            case 0:
                orderListView.isHidden = false
                orderMapView.isHidden = true
            case 1:
                orderListView.isHidden = true
                orderMapView.isHidden = false
             default:
                break;
        }
    }
    
   
    
    
    

    
   
    
    
//    @IBAction func indexChange(_ sender: UISegmentedControl) {
//        
//        switch typeSegment.selectedSegmentIndex {
//        case 0:
//            orderListView.isHidden = false
//            orderMapView.isHidden = true
//        case 1:
//            orderListView.isHidden = true
//            orderMapView.isHidden = false
//        default:
//            break;
//        }
//    }
    
    
    
    
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    override var preferredStatusBarStyle: UIStatusBarStyle {
        return .lightContent
    }
    
    
}


